package com.yun.zf.common.app.domain;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;

/**
 * <p>
 *
 * </p>
 *
 * @author cj
 * @since 2021-06-16
 */
@TableName("zf_house_score")
@Data
public class ZfHouseScore implements Serializable {

    private static final long serialVersionUID = 1L;

    private Long id;

    private Long basicId;
    /**
     * 省级区划代码
     */
    private Long provinceCode;

    /**
     * 城市编码
     */
    private Long cityCode;

    // 详情信息得分
    private BigDecimal detailScore;

    private BigDecimal detail;


    private BigDecimal infoScore;

    private BigDecimal info;

    // 房产证上传得分
    private BigDecimal czScore;
    private BigDecimal cz; // 产证进度

    // 业主上传
    private BigDecimal ownScore;
    private BigDecimal own;


    // 图片上传
    private BigDecimal picScore;
    private BigDecimal pic;


    @TableField(exist = false)
    private BigDecimal avgScore;
    @TableField(exist = false)
    private BigDecimal avgRate;

    public BigDecimal getAvgScore() {
        BigDecimal s = new BigDecimal("0");
        if (detailScore!=null){
          s=  s.add(detailScore);
        }
        if (infoScore!=null){
            s=   s.add(infoScore);
        }
        if (czScore!=null){
            s=    s.add(czScore);
        }
        if (ownScore!=null){
            s=   s.add(ownScore);
        }
        if (picScore!=null){
            s=   s.add(picScore);
        }
        BigDecimal rate= new BigDecimal("0");
        if (avgRate!=null){
             rate = avgRate.multiply(new BigDecimal("0.1"));
        }
        return (s.add(rate)).divide(new BigDecimal("6"), 1, BigDecimal.ROUND_HALF_UP);
    }

    public BigDecimal getAvgRate() {
        BigDecimal s = new BigDecimal("0");
        if (detail!=null){
            s=   s.add(detail);
        }
        if (info!=null){
            s=   s.add(info);
        }
        if (cz!=null){
            s=   s.add(cz);
        }
        if (own!=null){
            s=   s.add(own);
        }
        if (pic!=null){
            s=  s.add(pic);
        }
        return s.divide(new BigDecimal("5"), 1, BigDecimal.ROUND_HALF_UP);
    }
}
